package com.kfm.spring.servlet;


import com.kfm.spring.domain.Account;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

//@WebServlet("/account")
public class AccountServlet extends HttpServlet {

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        req.setCharacterEncoding("utf-8");

        String type = req.getParameter("type");

        switch (type){
            case "edit" -> edit(req, resp);
            case "delete" -> delete(Integer.parseInt(req.getParameter("id")));
        }
        // 查询所有账户
        // 调用service层的方法
        // 转发到account.jsp页面
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
    }

    public void delete(Integer id){
        // 删除账户
        // 调用service层的方法
        // 转发到account.jsp页面
    }


    public void edit(HttpServletRequest req, HttpServletResponse response){
        // 查询账户信息
        // 跳转到 edit.jsp 页面
    }


}
